<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    function foo(name, age) {
      console.log(`传入的name:`, name, age)
      console.log(arguments)
      console.log(typeof arguments)
      console.log(arguments[0])
      console.log(arguments[1])
      console.log(arguments[2])
      console.log(arguments[3])
      console.log("========================================")
      for (var i = 0; i < arguments.length; i++) {
        console.log(arguments[i])
      }
    }
    foo("why", 18, 1.88, '广州市')

    function sum() {
      var result = 0
      for (var i = 0; i < arguments.length; i++) {
        result += arguments[i]
      }
      return result
    }
    console.log(sum(10, 20))
    console.log(sum(10, 20, 30))
    console.log(sum(10, 20, 30, 40))

  </script>
</body>

</html>